#!/usr/bin/perl -I../lib -I../../../lib -w
use strict;
use warnings;
use 5.010;
use Calculator;
use Scalar::Util qw{blessed};
use Data::Dumper;

########## main

my $prompt = 'Parsing infix arithmetic expressions (CTRL-D to end in unix) ';
print $prompt;
while (my $input = <>) {
   chomp($input);
   my $tree = parse($input);
   if (blessed($tree)) {
       say Dumper(\$tree);
       require Calculator::PostfixCalc;
       say "postfix: ".$tree->ceval();
       require Calculator::EvalCalc;
       say "result: ".$tree->ceval();
       say Dumper(\%Calculator::symbol);
      }
      print $prompt;
  }
say "Bye!"

